/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/03/22
\**********************/
#ifndef __SD_LUASCRIPT_H__
#define __SD_LUASCRIPT_H__
#pragma once

#include <spdui/spdui.h>

namespace LuaPlus {
    class LuaState;
}

namespace DuiLib {

class SDLuaMgr;

class UILIB_API SDLuaScript : public SDIScript
{
public:
    SDLuaScript(LuaPlus::LuaState* luastate = nullptr);
    ~SDLuaScript();
public:
    bool DoFile(CDuiString file);
    LuaPlus::LuaState* GetState() const;
public:
    //SDIScript::it will called automatic
    virtual void Quit();
    //SDIScript::
    virtual void* HandleMessage(SDWindow* wnd, SPDUI_MSG msg, void* data1 = 0, void* data2 = 0);
    //SDIScript
    // called by SDWindow::~OnFinalMessage
    virtual void RemoveWnd(SDWindow* wnd);
    //SDIScript
    // called by CControlUI::~CControlUI->SDWindow::~OnRemoveControl
    virtual void RemoveCtrl(SDWindow* wnd, CControlUI* ctrl);
    //SDIScript
    // called by CDialogBuilder::_Parse->SDWindow::~OnAfterCreateControl
    virtual void AddCtrl(SDWindow* wnd, CControlUI* ctrl, LPCTSTR ctrlmetaname);
    //SDIScript
    // called by SDWindow::SDWindow
    virtual void AddWnd(SDWindow* wnd, LPCTSTR metaname);
protected:
    SDLuaMgr *m_mgr;
};

}
#endif //__SD_LUASCRIPT_H__
